package com.yanqu.road.server.cmd.orewar.cross;

import com.yanqu.road.entity.crossorewar.CrossOreWarRecord;
import com.yanqu.road.pb.orewar.OreWarProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.activity.orewar.OreWarMgr;
import com.yanqu.road.server.pb.OreWarPb;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;

import java.util.ArrayList;
import java.util.List;

@Cmd(code = Protocol.S_CROSS_ORE_WAR_RECORD_SYNC, desc = "跨服同步记录信息")
public class CrossRecordSyncCmd extends AbstractCommand {

	int activityId;

	List<CrossOreWarRecord> oreWarRecordList = new ArrayList<>();

	boolean isAllSync;

	int groupId;
	@Override
	public boolean parseData(YanQuMessage packet) throws Exception {
		return true;
	}

	@Override
	public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
		OreWarProto.CrossRecordSyncMsg crossSyncMsg = OreWarProto.CrossRecordSyncMsg.parseFrom(packet.getBytes());

		activityId = crossSyncMsg.getActivityId();
		oreWarRecordList = OreWarPb.parseCrossOreWarRecordList(crossSyncMsg.getRecordListList());
		isAllSync = crossSyncMsg.getIsAllSync();
		groupId = crossSyncMsg.getGroupId();
		OreWarMgr.crossRecordSync(activityId,oreWarRecordList,isAllSync,groupId);
	}

	@Override
	public void sendData(GamePlayer player) {

	}
}
